package com.qcby.controller;

import com.qcby.common.ClassNote.ShowByPage;
import com.qcby.entity.ClassNote;
import com.qcby.entity.Exam;
import com.qcby.entity.LessonPlan;
import com.qcby.entity.Result;
import com.qcby.service.ClassNoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;

@Controller
@Api(tags = "学生上课笔记接口")
@RequestMapping("/ClassNote")
public class ClassNoteController {

    @Autowired
    ClassNoteService classNoteService;

    @GetMapping("/ShowByPage")
    @ApiOperation(value = "分页展示笔记信息")
    @ResponseBody
    public Result<List<ClassNote>> showNoteInfoByPage(ShowByPage info){
        System.out.println(info);
        return classNoteService.showNoteInfoByPage(info);
    }

    @GetMapping("/GetNoteCount")
    @ApiOperation(value = "获取满足条件的教案数量")
    @ResponseBody
    public Result<Integer> getNoteCount(ShowByPage info) {
        return classNoteService.getNoteCount(info);
    }

    @PostMapping("/AddNote")
    @ApiOperation(value = "添加笔记信息")
    @ResponseBody
    public Result<ClassNote> addNote(ClassNote info){
        return classNoteService.addNote(info);
    }

    @DeleteMapping("/DeleteNote")
    @ApiOperation(value = "删除笔记信息")
    @ResponseBody
    public Result<Integer> DeleteNote(int id){
        return classNoteService.deleteNote(id);
    }


    @PostMapping("/GetNoteById")
    @ApiOperation(value = "通过id获取笔记信息")
    @ResponseBody
    public Result<ClassNote> getNoteById(int id){
        return classNoteService.getNoteById(id);
    }


    @PostMapping("/UpdateNote")
    @ApiOperation(value = "修改笔记信息")
    @ResponseBody
    public Result<ClassNote> UpdateNote(ClassNote info){
        return classNoteService.updateNote(info);
    }
    @PostMapping("/AddExam")
    @ApiOperation(value = "添加考试")
    @ResponseBody
    public Result<Exam> addExam(ClassNote info){
        return classNoteService.addExam(info);
    }

    @PostMapping("/GenerateQuestion")
    @ApiOperation(value = "生成考试题")
    @ResponseBody
    public Result<Integer> generateQuestion(
            @RequestParam("e_id") int e_id,
            @RequestParam("content") String content
    ) throws IOException {
        return classNoteService.generateQuestion(e_id,content);
    }
}
